# USELESS MACHINE
This repository is in the public domain.

## Materials:
* Single joint toggle-switch (6mm)
* MG90S micro servo
* Arduino UNO R3(havent tested w/other boards)
* 3 Wires for servo, 2 for the switch
* COM5 USB cable
* Computer with a USB port
* housing for machine
* Screws
* finger for servo

## Building with Makefiles(WIP)
The Makefile only works with GNU Make. It relies on files from [arduino-makefile](https://github.com/sudar/Arduino-Makefile) to build. You will also need arduino's cli tools(avrdude, etc). Consult Arduino.mk and the rest of arduino-makefile's documentation in the event of building issues. Some paths in it are [hard-coded](https://github.com/sudar/Arduino-Makefile/wiki/For-Package-Developers) and may need to be tweaked in some way.

Look at the "PATHS YOU NEED TO SET UP" section in Arduino.mk first.


## Code Explanation
	1. '#include' statement includes Arduino's code for moving the servo
	
	2. lines 5-9 set up the positions for the servo
	and the pin to attach the switch to.
	
	3. The setup method attaches the servo to another pin
		a. It then starts reading input from the switch, pulling up floating bits to 1 so the servo can be stable
		b. It makes sure the servo is in its initial position
	
	4. Loop method checks if the switch is turned on. Once the finger comes up and turns it off, the finger and switch are back to the start.


## Circuitry Instructions 
	1. Download the Arduino IDE and remember this folder's location
		Mac: https://www.arduino.cc/en/Guide/macOS/
		Windows: https://www.arduino.cc/en/guide/windows
		Linux: https://www.arduino.cc/en/Guide/Linux/
		
	2. Place the servo face up in the larger housing component, make sure the holes on its sides match up to the holes on the component.
	
	3. screw in the two smaller screws into the two holes on the servo's sides. 
	
	4. Place the finger in the way that the fingertip is facing up towards the "door" part of the upper housing
	
	5. Plug in the wires to the corresponding pins on the servo
		a. the wire connected to the servo pin(indicated with a ~, noted in the code as servoPin) should be connected to the yellow-orange wire of the servo.
		b. the wire in the middle should go to power(labeled 5V on the arduino)
		c. The brown wire on the servo should connect to a ground pin(labeled GND on the arduino)
	
	6. Wire up the switch to the correct pins 
		a. Plug in the switch's middle wire to on of the GND pins.
	
	 	b. Plug in the left or right part into pin 2 on the arduino
	
	7. Make sure the arduino is plugged into the computer

	8. If so, upload the sketch serial_with_motor.ino through the Arduino IDE or use `make upload`
	
	9. Play with the switch and see which position causes the finger to move up. make sure to wait a few seconds(5 at most) after flipping the switch
	
	10. With the switch in the off position, place it in the housing so that the lever
	points in the direction of the usb port

	11. Your useless machine should be operational!
